﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace snat.model {
    public class Message : IComparable<Message> {
        
        /// <summary>
        /// ID of the message from the database
        /// </summary>
        public int ID { get; private set; }

        /// <summary>
        /// IDonNetwork from the database
        /// </summary>
        public string IDonNetwork { get; private set; }
        /// <summary>
        /// Sender of the message as network model node
        /// </summary>
        public BaseNode Sender { get; private set; }
        /// <summary>
        /// List of recipients of the message as network model nodes
        /// </summary>
        public List<BaseNode> Recipients { get; private set; }
        /// <summary>
        /// Whether the message is received by all senders connections or not
        /// </summary>
        public bool Restricted { get; private set; }
        /// <summary>
        /// Texual contents of the message
        /// </summary>
        public string Data { get; private set; }
        /// <summary>
        /// Timestamp of the message
        /// </summary>
        public DateTime Timestamp { get; private set; }

        public Message(int _id, BaseNode _sender, List<BaseNode> _recipients, String _idOnNetwork, bool _restricted, DateTime _timestamp, String _data) {
            this.ID = _id;
            this.Sender = _sender;
            this.Recipients = _recipients;
            this.IDonNetwork = _idOnNetwork;
            this.Restricted = _restricted;
            this.Timestamp = _timestamp;
            this.Data = _data;
        }

        public int CompareTo(Message other) {
            return other.ID.CompareTo(ID);
        }
    }
}
